import { useThemeStore } from "@/store/modules/theme";
import { watch } from "vue";

export const useThemeChart = (
    echartsInstance: null,
    initChart: () => void,
    updateChart: () => void,
    screenAdapter?: () => void
) => {
    const themeStore = useThemeStore();

    watch(
        () => themeStore.theme,
        () => {
            if (echartsInstance.value) {
                echartsInstance.value.dispose();
                initChart();
                screenAdapter?.();
                updateChart();
            }
        }
    );

    return {
        themeStore
    };
};